package com.stars.controller.system;
import com.stars.services.system.SysCompanyAccessServices;
import com.stars.services.system.SysCompanyConfigServices;
import com.stars.entity.dto.system.SysCompanyDTO;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;

import com.stars.common.annotation.Log;
import com.stars.common.base.BaseMsg;

import com.stars.common.base.ResultMsg;
import com.stars.controller.BaseController;
import com.stars.common.enums.OperationType;
import org.springframework.web.bind.annotation.PostMapping;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.servlet.http.HttpServletRequest;
import com.stars.common.tree.TreeJson;
import java.util.List;
/**
 * @Title: 公司管理 mybatis dao
 * @author dj
 * @date 2019-10-10 20:48:07
 * @version V1.0
 *
 */
@Slf4j
@RestController
@RequestMapping("/sysCompanyCtl")
@Api(tags ="公司管理")
public class SysCompanyCtl extends BaseController{

   @Autowired
   private SysCompanyAccessServices  sysCompanyAccessServicesImpl;
   @Autowired
   private SysCompanyConfigServices  sysCompanyConfigServicesImpl;




    /**
    * 保存
    * @param treeJson
    * @return 成功失败
    * @throws Exception
    */
    @PostMapping(value = "/add")
    @ApiOperation(value = "公司管理"+ BaseMsg.MODULAR_ADD,notes = "公司管理"+BaseMsg.MODULAR_ADD)
    @Log(detail = "公司管理"+BaseMsg.MODULAR_ADD,operationType = OperationType.INSERT)
    public ResultMsg addSysCompany(TreeJson treeJson,HttpServletRequest request) throws Exception{
        setAddBaseApp(treeJson,request);
        return sysCompanyConfigServicesImpl.saveTree(treeJson);
    }
    /**
    * 获取全部的树形数据
    *
    * @return
    * @throws Exception
    */
    @PostMapping("/findTree")
    @ApiOperation(value = "获取全部的资源数据",notes = "获取全部的资源数据")
    @Log(detail = "公司管理"+ BaseMsg.MODULAR_PAGE,operationType = OperationType.SELECT)
    public ResultMsg findTree(SysCompanyDTO sysCompanyDTO,HttpServletRequest request) throws Exception {
        List<SysCompanyDTO> treeList = sysCompanyAccessServicesImpl.findTreeList(sysCompanyDTO);
        return ResultMsg.success(treeList);
    }

}